package org.foreningsgatan.genetics.grid;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.foreningsgatan.genetics.Program;
import org.foreningsgatan.genetics.SimulationEnvironment;
import org.gridgain.grid.GridException;
import org.gridgain.grid.GridJob;
import org.gridgain.grid.GridJobResult;
import org.gridgain.grid.GridTaskSplitAdapter;

public class SimulationTask<T extends Serializable, S extends Serializable> extends GridTaskSplitAdapter<Collection<Program<T, S>>, Program<T, S>>{
	
	private static final long serialVersionUID = 1L;
	
	private SimulationEnvironment<T, S> environment;

	@Override
	protected Collection<? extends GridJob> split(int gridSize, Collection<Program<T, S>> programs) throws GridException {
        List<GridJob> jobs = new ArrayList<GridJob>(programs.size());
		for (Program<T, S> program : programs) {
            jobs.add(new ProgramTask<T, S>(environment, program));
			
		}
		return null;
	}

	@Override
	public Program<T, S> reduce(List<GridJobResult> results) throws GridException {
		// TODO Auto-generated method stub
		return null;
	}

}
